package com.sheng.center.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.sheng.center.entity.Plan;
import com.sheng.center.service.PlanService;

public class PlanAction extends ActionSupport implements ModelDriven<Plan> {
	
	protected String forwardView;
	protected static final String ADD_JSP = "/WEB-INF/page/Plan_add.jsp";
	protected static final String EDIT_JSP = "/WEB-INF/page/Plan_edit.jsp";
	protected static final String LIST_JSP = "/WEB-INF/page/Plan_list.jsp";
	protected static final String PlanExamine_JSP = "/WEB-INF/page/Plan_examine.jsp";
	protected static final String STUDENT_Examine_JSP = "/WEB-INF/page/Student_examine.jsp";
	protected static final String EditExamine_JSP = "/WEB-INF/page/Plan_editExamine.jsp";
    private Plan plan = new Plan();
    private List<Plan> list;
	private PlanService planService;
	@Override
	public Plan getModel() {
		return plan;
	}
	
	
	public String openAdd(){
		setForwardView(ADD_JSP);
		return SUCCESS;
	}
	public String openEdit() {
		System.out.println("===需要修改的id==="+plan.getId());
		plan = planService.findById(plan);
		setForwardView(EDIT_JSP);
		return SUCCESS;
	}
	
	public String openEditExamine() {
		plan = planService.findById(plan);
		setForwardView(EditExamine_JSP);
		return SUCCESS;
	}
	
	public String list() {
		list = planService.findAllList(plan);
		setForwardView(LIST_JSP);
		return SUCCESS;
	}
	
	/**
	 * 
	 * @Title: planExamine
	 * @Description: 打开招聘计划审核页面
	 * @param @return 参数
	 * @return String 返回类型
	 * @author huangshengjun 1532950421@qq.com
	 * @date 2019年12月17日 下午6:00:02 
	 * @throws
	 */
	public String planExamine() {
		list = planService.findAllList(plan);
		setForwardView(PlanExamine_JSP);
		return SUCCESS;
	}
	
	/**
	 * 
	 * @Title: listExamine
	 * @Description: 查询已经审核的招聘计划给学生报名
	 * @param @return 参数
	 * @return String 返回类型
	 * @author huangshengjun 1532950421@qq.com
	 * @date 2019年12月21日 下午8:11:56 
	 * @throws
	 */
	public String listExamine() {
		list = planService.findAllListExamine(plan);
		setForwardView(STUDENT_Examine_JSP);
		return SUCCESS;
	}
	
	public String add() {
		plan.setIsExamine(0);
		planService.add(plan);
		return list();
	}
	
	public String edit() {
		plan.setIsExamine(0);
		planService.edit(plan);
		return list();
	}
	public String delete() {
		plan = planService.findById(plan);
		planService.delete(plan);
		return list();
	}
	/**
	 * 
	 * @Title: planOne
	 * @Description: 通过审核，置为1
	 * @param @return 参数
	 * @return String 返回类型
	 * @author huangshengjun 1532950421@qq.com
	 * @date 2019年12月13日 下午11:33:33 
	 * @throws
	 */
	public String planOne() {
		plan = planService.findById(plan);
		plan.setIsEnough(0);//设置人数为满
		planService.planOne(plan);
		return planExamine();
	}
	/**
	 * 
	 * @Title: planTwo
	 * @Description: 不通过，置为2
	 * @param @return 参数
	 * @return String 返回类型
	 * @author huangshengjun 1532950421@qq.com
	 * @date 2019年12月13日 下午11:33:58 
	 * @throws
	 */
	public String planTwo() {
		plan = planService.findById(plan);
		planService.planTwo(plan);
		return planExamine();
	}
	/**
	 * 
	 * @Title: planEnough
	 * @Description: 人数已满。置为1.禁止提交报名
	 * @param @return 参数
	 * @return String 返回类型
	 * @author huangshengjun 1532950421@qq.com
	 * @date 2019年12月20日 下午8:08:17 
	 * @throws
	 */
	public String planEnough() {
		plan = planService.findById(plan);
		planService.planEnough(plan);
		return planExamine();
	}

	public String getForwardView() {
		return forwardView;
	}

	public void setForwardView(String forwardView) {
		this.forwardView = forwardView;
	}

	public Plan getPlan() {
		return plan;
	}

	public void setPlan(Plan plan) {
		this.plan = plan;
	}


	public PlanService getPlanService() {
		return planService;
	}

	public List<Plan> getList() {
		return list;
	}

	public void setList(List<Plan> list) {
		this.list = list;
	}

	public void setPlanService(PlanService planService) {
		this.planService = planService;
	}

}
